
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class UmsRoleServiceImpl implements UmsRoleService  {

    @Resource
    private UmsRoleMapper umsRoleMapper;

    /**
     * 获取 UmsRole 分页列表
     */
    @Transactional
    public IPage getUmsRolePagination( PaginationVo paginationVo, UmsRoleQuery umsRoleQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<UmsRoleEntity> lqs = new LambdaQueryWrapper();
        umsRoleMapper.selectPage(page, lqs);

        List<UmsRoleEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 UmsRole 所有数据
     *
    */
    @Transactional
    public List<UmsRoleEntity> getUmsRoleAllList( UmsRoleQuery umsRoleQuery ) throws Exception {

        LambdaQueryWrapper<UmsRoleEntity> lqs = new LambdaQueryWrapper();
        List<UmsRoleEntity> list = umsRoleMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 UmsRole 详情
    */
    @Transactional
    public UmsRoleEntity getUmsRoleDetail( Long id) throws Exception {

        UmsRoleEntity umsRole = umsRoleMapper.selectById(id);
        return umsRole;
    }


    /**
     * 新增 UmsRole
     * */
    @Transactional
    public void addUmsRole(UmsRoleVo umsRoleVo) throws Exception {

        UmsRoleEntity umsRole = new UmsRoleEntity();
        ReflectionCopy.copyProperties( umsRole, umsRoleVo );
        umsRoleMapper.insert(umsRole);
        return;
    }


    /**
     * 更新 UmsRole
     * */
    @Transactional
    public void updateUmsRole( UmsRoleVo umsRoleVo) throws Exception {

        if( umsRoleVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        UmsRoleEntity umsRole = new UmsRoleEntity();
        ReflectionCopy.copyProperties( umsRole, umsRoleVo );
        umsRoleMapper.updateById(umsRole);
        return;
    }

    /**
     * 删除 UmsRole
     * */
    @Transactional
    public void batchRemoveUmsRole( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        umsRoleMapper.deleteBatchIds(ids);
    }

}

      